using NUnit.Framework;
using Sandia.MVCFramework.Data;
using System;
using System.Collections.Generic;
using System.Text;

namespace Sandia.MVCFramework.Test
{
    [TestFixture]
    public class DataTests : FailOnErrorLoggingTestFixture
    {
        [Test]
        public void DataPacketTest()
        {
            TestData data = new TestData();
            string requesterID = "requesterID";
            DataPacket packet = new DataPacket(data, requesterID);

            // Make sure the test data and the packet's data are the same.
            Assert.AreSame(data, packet.Data, "The packet does not have the correct data in it.");

            // Make sure the data type is set correctly.
            Assert.AreEqual(typeof(TestData), packet.DataType, "The packet does not have the correct data type in it.");

            // Make sure the requester ID is set correctly.
            Assert.AreEqual(requesterID, packet.RequesterID, "The packet does not have the correct requester ID in it.");

            // Check the setter for data.
            TestData newData = new TestData();
            packet.Data = newData;

            Assert.AreSame(newData, packet.Data, "Data not set correctly.");
            Assert.AreEqual(typeof(TestData), packet.DataType, "Data not set correctly.");

            // Check the setter for the packet ID.
            string packetID = "test";
            packet.PacketID = packetID;
            Assert.AreSame(packetID, packet.PacketID, "Packet ID not set correctly.");

            string newRequesterID = "newRequesterID";
            packet.RequesterID = newRequesterID;
            Assert.AreSame(newRequesterID, packet.RequesterID, "Requester ID not set correctly.");
        }
    }

    class TestData : IData
    {
    }
}
